package org.jwos.platform.domain;

public class GlobalConfig {
	
	private String serverName;
	
	private String serverHostName;
	
	private String serverPort;
	
	private String serverBaseUrl;
	
	private String serverWorkFolder;
	
	private String mailHostName;
	
	private String mailFetchServer;
	
	private String mailFetchPort;
	
	private String mailProtocol;
	
	private String mailSmtpServer;
	
	private String mailSmtpPort;
	
	private boolean mailSmtpAuthenticated;
	
	private String messageServer;
	
	private String messagePort;
	
	private String messageHostName;
	
	public GlobalConfig() {		
	}
	
	public String getCompleteBaseUrl() {
		String url = "http://" + this.getServerHostName();
		
		if(isValidPort(this.getServerPort())) {
			url += ":" + this.getServerPort();
		}
		
		if(getServerBaseUrl()!=null && getServerBaseUrl().length()>0 && !getServerBaseUrl().equals("/")) {
			url += "/" + this.getServerBaseUrl();
		}
		
		return url;
	}
	
	public boolean isValidPort(String str) {
		boolean result = false;
		
		try {
			int number = Integer.parseInt(str);
			if(number>0) {
				result = true;
			}			
		} catch (NumberFormatException e) {
		}
		
		return result;
	}

	public String getServerName() {
		return serverName;
	}

	public void setServerName(String serverName) {
		this.serverName = serverName;
	}

	public String getServerHostName() {
		return serverHostName;
	}

	public void setServerHostName(String serverHostName) {
		this.serverHostName = serverHostName;
	}

	public String getServerPort() {
		return serverPort;
	}

	public void setServerPort(String serverPort) {
		this.serverPort = serverPort;
	}

	public String getServerBaseUrl() {
		return serverBaseUrl;
	}

	public void setServerBaseUrl(String serverBaseUrl) {
		this.serverBaseUrl = serverBaseUrl;
	}

	public String getServerWorkFolder() {
		return serverWorkFolder;
	}

	public void setServerWorkFolder(String serverWorkFolder) {
		this.serverWorkFolder = serverWorkFolder;
	}	

	public String getMailHostName() {
		return mailHostName;
	}

	public void setMailHostName(String mailHostName) {
		this.mailHostName = mailHostName;
	}

	public String getMailFetchServer() {
		return mailFetchServer;
	}

	public void setMailFetchServer(String mailFetchServer) {
		this.mailFetchServer = mailFetchServer;
	}

	public String getMailFetchPort() {
		return mailFetchPort;
	}

	public void setMailFetchPort(String mailFetchPort) {
		this.mailFetchPort = mailFetchPort;
	}

	public String getMailProtocol() {
		return mailProtocol;
	}

	public void setMailProtocol(String mailProtocol) {
		this.mailProtocol = mailProtocol;
	}

	public String getMailSmtpServer() {
		return mailSmtpServer;
	}

	public void setMailSmtpServer(String mailSmtpServer) {
		this.mailSmtpServer = mailSmtpServer;
	}

	public String getMailSmtpPort() {
		return mailSmtpPort;
	}

	public void setMailSmtpPort(String mailSmtpPort) {
		this.mailSmtpPort = mailSmtpPort;
	}

	public boolean isMailSmtpAuthenticated() {
		return mailSmtpAuthenticated;
	}

	public void setMailSmtpAuthenticated(boolean mailSmtpAuthenticated) {
		this.mailSmtpAuthenticated = mailSmtpAuthenticated;
	}

	public String getMessageServer() {
		return messageServer;
	}

	public void setMessageServer(String messageServer) {
		this.messageServer = messageServer;
	}

	public String getMessagePort() {
		return messagePort;
	}

	public void setMessagePort(String messagePort) {
		this.messagePort = messagePort;
	}

	public String getMessageHostName() {
		return messageHostName;
	}

	public void setMessageHostName(String messageHostName) {
		this.messageHostName = messageHostName;
	}
}
